package com.yequan.work;

import org.apache.commons.codec.binary.*;
import org.slf4j.*;

public class CarpoolEncryptUtil {

    private static Logger logger = LoggerFactory.getLogger(CarpoolEncryptUtil.class);

    public static String checkAndDecryptPhone(String phone) throws Exception {
        try {
            return new String(Base64.decodeBase64(phone));
        } catch (Exception e) {
            logger.error("decryptPhone fail. phone:{}", phone, e);
            throw new Exception("");
        }
    }

    public static String encryptBase64(String value) {
        return new String(Base64.encodeBase64(value.getBytes()));
    }

    public static void main(String[] args) throws Exception {
        String phone = checkAndDecryptPhone("MTg4NjA5MTgwMjc=");
//        String phone = checkAndDecryptPhone("VRd3BaOJukfD9NIGui09Kd7Nhs6TM%2F9gK%2FQzjfWYuShOeaXown53PYbKLo8fTun1BSVevZ9ifEkKhbcLuOOJO0hEAU9U4vOeXZlldllFPIvc0NB%20DbqsH223htrfqxAU");
        System.out.println(phone);

//        System.out.println(encryptBase64("13029778447"));
    }

}
